package cn.xshi.sys.service.impl;
import java.util.List;
import java.util.Map;

import cn.xshi.sys.dao.SysIpFrozenDao;
import cn.xshi.sys.init.GlobalPersistentComponent;
import cn.xshi.sys.model.SysIpFrozen;
import cn.xshi.sys.service.SysIpFrozenService;
import org.springframework.stereotype.Service;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import javax.annotation.Resource;
/**
 * @Desc 平台IP冻结账户
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class SysIpFrozenServiceImpl extends BaseService implements SysIpFrozenService {

	@Resource
	private SysIpFrozenDao sysIpFrozenDao;

	@Resource
    GlobalPersistentComponent globalPersistentComponent;

	/**
	* 分页
	* @param condition 
	* @return
	*/
	public List<SysIpFrozen> getSysIpFrozenListByCondition(Map<String,Object> condition){
		try{
			return sysIpFrozenDao.getSysIpFrozenListByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public SysIpFrozen getSysIpFrozenById(String id){
		try{
			return sysIpFrozenDao.getSysIpFrozenById(id);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param sysIpFrozen
	* @return
	*/
	public int addSysIpFrozen(SysIpFrozen sysIpFrozen){
		int i = 0;
		try {
			sysIpFrozen.setCreateId(getCurrentAccountId());
			sysIpFrozen.setCreateTime(getDate());
			sysIpFrozenDao.addSysIpFrozen(sysIpFrozen);
			globalPersistentComponent.initSysIpFrozen();
			i = 1;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param sysIpFrozen
	* @return
	*/
	public int updateSysIpFrozen(SysIpFrozen sysIpFrozen){
		int i = 0;
		try {
			sysIpFrozen.setUpdateId(getCurrentAccountId());
			sysIpFrozen.setUpdateTime(getDate());
			sysIpFrozenDao.updateSysIpFrozen(sysIpFrozen);
			globalPersistentComponent.initSysIpFrozen();
			i = 1;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delSysIpFrozen(Map<String,Object> condition){
		int i = 0;
		try {
			sysIpFrozenDao.delSysIpFrozen(condition);
			globalPersistentComponent.initSysIpFrozen();
			i = 1;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
	
	/**
	 * 获取所有集合
	 * @param condition
	 * @return
	 */
	public List<SysIpFrozen> getSysIpFrozenListAllByCondition(Map<String,Object> condition){
		try{
			return sysIpFrozenDao.getSysIpFrozenListAllByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}
}
